$(function() {
	$('#vue_vm_list div').hide();
});

var allowanceApply = {
	allowanceApplyId: '',
	relationId: '',
	relationName: '',
	relationCardId: '',
	relationType: '',
	approveStatus: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
	applyDate: '',
};

var view = {
	data: allowanceApply
};

if($('#vue_vm').length > 0) {
	var vue_vm = new Vue({
		el: '#vue_vm',
		data: view
	});
}

findAll();

function save() {
	view.data.relationType = (view.data.relationType==''? 0: parseInt(view.data.relationType));
	view.data.approveStatus = (view.data.approveStatus==''? 0: parseInt(view.data.approveStatus));

	save_basic(path+'/allowanceApply/save', {allowanceApply:view.data}, function() {
		findAll();
	});
}

function findAll() {
	if($('#vue_vm_list div').length==0) {return;}
	$('#vue_vm_list div').hide();

	findAll_basic(path+'/allowanceApply/findAll', function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				allowanceApply_approve_ok:function(todo) {
					if(confirm('确实要通过吗？')) {
						save_basic_by_json(path+'/allowanceApply/approve', {id:todo.allowanceApplyId, approveStatus:1}, function() {
							$('#'+todo.allowanceApplyId+'_div').remove();
							todo.approveStatus = 1;
							alert('通过成功');
						});
					}
				},
				allowanceApply_approve_deny:function(todo) {
					if(confirm('确实要拒绝吗？')) {
						save_basic_by_json(path+'/allowanceApply/approve', {id:todo.allowanceApplyId, approveStatus:2}, function() {
							$('#'+todo.allowanceApplyId+'_div').remove();
							todo.approveStatus = 2;
							alert('拒绝成功');
						});
					}
				}
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/allowanceApply/deleteBatch');
}
